package org.example.io;

import java.io.BufferedReader;
import java.io.FileReader;

public class TestBufferedReader {
    public static void main(String[] args) throws Exception{
        //创建字符缓冲输入流
        BufferedReader reader = new BufferedReader(new FileReader("D:\\tmp\\111.txt"));
        //输出数据
        int len;
        while ((len = reader.read())!=-1){
            System.out.print((char) len);
        }
        System.out.println();

        //使用数组
        char[] bytes = new char[1024];
        len = 0;
        while ((len = reader.read(bytes))!=-1){
            System.out.print(new String(bytes,0,len));
        }
        System.out.println();

        //关闭流
        reader.close();
    }
}
